'use strict';
// import {Sequelize, DataTypes, Model} from 'sequelize';

const {Model} = require('sequelize');
module.exports = (sequelize, dataTypes) => {
  class category extends Model {
    static associate(models) {
      // define association here
    }
  };
  category.init({
    id: {
      allowNull: false,
      autoIncrement: true,
      primaryKey: true,
      type: DataTypes.INTEGER,
      comment: 'id'
    },
    name: {
      type: DataTypes.STRING,
      allowNull: false,
      defaultValue: '',
      comment: '分类名'
    }, 
    pid: {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: '父分类id'
    },
    created_at: {
      allowNull: false,
      type: DataTypes.DATE,
      filed: 'created_at',
      comment: '创建时间'
    },
    updated_at: {
      allowNull: false,
      type: DataTypes.DATE,
      filed: 'updated_at',
      comment: '更新时间'
    }
  }, {
    sequelize,
    modelName: 'category',
    tableName: 'category'
  });
  return category;
};